<?php
    session_start();
    //$_SESSION['uid']="1234561";
	if($_SESSION['uid']==""||$_SESSION['level']!=2){
		header("Location: ./login.php");
		exit();
	}
	include('/php/tool/submitValidate.php');
	include('/php/tool/pdo.php');
	include('/php/class/public-data.class.php');
	include('/php/bll/PublicDataBLL.php');
    include('/php/class/student-dormitory-exchanging.class.php');
	include('/php/bll/StudentDormitoryExchangingBLL.php');
	
    //(int)$property= isset($_GET['property']) ? $_GET['property'] : 0;
    $student_id = isset($_GET['student_id']) ? $_GET['student_id'] : '';
	$grade= isset($_GET['grade']) ? $_GET['grade'] : 0;
	$major= isset($_GET['major']) ? $_GET['major'] : 0;
	$class= isset($_GET['class']) ? $_GET['class'] : 0;
	$page = isset($_GET['page']) ? $_GET['page'] : 0;
	$pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 20;
	$search = isset($_GET['search']) ? $_GET['search'] : '';

	/*if(!$apartmentBLL->apartmentListViewValidate($page,$pageSize,$property)){
		header("Location: http://www.baidu.com");
		exit();
    }*/
    $publicData=new PublicDataBLL();
    $studentInfo=$publicData->getStudentInformation($student_id);
	$name=$studentInfo['name'];
	$gender=$studentInfo['gender'];
	$StudentDormitoryExchangingBLL=new StudentDormitoryExchangingBLL();//$_SESSION['uid']
	//$instructorAllocateList=$StudentDormitoryExchangingBLL->getInstructorAllocateList($_SESSION['uid']);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="lib/webuploader/0.1.5/webuploader.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>宿舍调换</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 宿舍管理 <span class="c-gray en">&gt;</span> 宿舍调换 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

	<div class="text-c">
		<!--<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>-->
		<div class="cl pd-5 mybg-2 bk-gray">
            <span class="l">
                
            </span>
			<span class="r">
				<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
			</span>
		</div>
	</div>

	<div class="mt-10">
		<form action="student-dormitory-exchanging.php" method="get" class="form-horizontal mybg-2 bk-gray pt-5 pb-5">
            <div class="row cl mb-5">
                <label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">姓名：</label>
				<div class="formControls col-xs-8 col-sm-3">
                    <input  id="name" name="name" value="<?php echo $name;?>" type="text" class="input-text" style="width:100%"  disabled="disabled">
                    <input  id="student_id" name="student_id" value="<?php echo $student_id;?>" type="text" class="input-text" style="display:none">
					<input  id="gender" name="gender" value="<?php echo $gender;?>" type="text" class="input-text" style="display:none">
				</div>
            </div>
            <div class="row cl mb-5">
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">年级：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="grade_select" name="grade" class="select" size="1" style="height:31px">
						<?php
                            //获取年级列表
                            $gradeList=$publicData->getInstructorGradeList($_SESSION['uid']);
							foreach($gradeList as $myGrade){
								if($myGrade['grade']==$grade){
									echo '<option value="'.$myGrade['grade'].'" selected="">'.$myGrade['grade'].'</option>';
								}else{
									echo '<option value="'.$myGrade['grade'].'">'.$myGrade['grade'].'</option>';
								}
                            }
                            if($grade==0){
                                if($gradeList[0]['grade']!=null)
                                    $grade=$gradeList[0]['grade'];
                            }
						?>
					</select>
				</div>
				<label class="form-label col-xs-1" style="width:120px;margin:0;padding:0;line-height:31px;">专业：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="major_select" name="major" class="select" size="1" style="height:31px">
						<?php
                            //获取专业列表
                            $majorList=$publicData->getInstructorMajorList($_SESSION['uid']);
							foreach($majorList as $myMajor){
								if($myMajor['major_id']==$major){
									echo '<option value="'.$myMajor['major_id'].'" selected="">'.$myMajor['major_name'].'</option>';
								}else{
									echo '<option value="'.$myMajor['major_id'].'">'.$myMajor['major_name'].'</option>';
								}
                            }
                            if($major==0){
                                if($majorList[0]['major_id']!=null)
                                    $major=$majorList[0]['major_id'];
                            }
						?>
					</select>
				</div>
			</div>
			<div class="row cl mb-5">
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">班级：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<select id="class_select" name="class" class="select" size="1" style="height:31px">
						<?php
                            //获取班级列表
                            $classList=$majorList=$publicData->getInstructorClassList($_SESSION['uid']);
							foreach($classList as $myClass){
								if($myClass['class']==$class){
									echo '<option value="'.$myClass['class'].'" selected="">'.$myClass['class'].'</option>';
								}else{
									echo '<option value="'.$myClass['class'].'">'.$myClass['class'].'</option>';
								}
                            }
                            if($class==0){
                                if($classList[0]['class']!=null)
                                    $class=$classList[0]['class'];
                            }
						?>
					</select>
				</div>
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">姓名或学号：</label>
				<div class="formControls col-xs-8 col-sm-3">
					<input  id="search" name="search" value="<?php echo $search;?>" type="text" class="input-text" style="width:100%"  placeholder="">
					<label id="search-error" class="error valid" for="search" style="display:none;">这是必填字段</label>
				</div>
				<button id="btn-search"  class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
			</div>
		</form>
	</div>

	<div class="mt-20">
			<table class="table table-border table-bordered table-hover table-bg">
					<thead>
						<tr>
							<th colspan="9" scope="col">学生信息管理</th>
						</tr>
						<tr class="text-c">
							<th width="120">学号</th>
							<th width="100">姓名</th>
							<th width="100">性别</th>
							<th width="100">年级</th>
							<th width="170">专业</th>
							<th width="100">班级</th>
                            <th width="120">公寓</th>
							<th width="80">宿舍</th>
							<th width="70">操作</th>
						</tr>
					</thead>
					<tbody>
					<?php //$_SESSION['uid']
						$result=$StudentDormitoryExchangingBLL->getStudentList($_SESSION['uid'],$student_id,$grade,$major,$class,$search,$page,$pageSize);
                        $studentList=$result['studentList'];
                        $pageMax=$result['page'];
						foreach($studentList as $student){
							echo '<tr class="text-c">
								<td class="student_id">'.$student['student_id'].'</td>
								<td class="name">'.$student['name'].'</td>
								<td class="gender" style="display:none">'.$student['gender'].'</td>
								<td class="gender_name">'.($student['gender']==1?'女':'男').'</td>
								<td class="grade">'.$student['grade'].'</td>
								<td class="major_name">'.$student['major_name'].'</td>
                                <td class="class">'.$student['class'].'</td>
                                <td class="apartment_name">'.$student['apartment_name'].'</td>
								<td class="dormitory_id">'.$student['dormitory_id'].'</td>
								<td><a title="调换" href="javascript:;" onClick="exchangeStudent(this)" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6a7;</i></a></td>
							</tr>';
						}
					?>
					</tbody>
				</table>
	</div>
	<div class="modal-footer">
		<a class="btn" href="<?php echo './student-dormitory-exchanging.php?&grade='.$grade.'&major='.$major.'&class='.$class.'&page='.($page-1>0?$page-1:0).'&pageSize='.$pageSize.'&search='.$search; ?>">上一页</a>
			<span><select  id="jump_page" name="page" class="btn">
				<?php
					if($pageMax>0){
						for($i=0;$i<$pageMax;$i++){
							if($i==$page){//selected=""
								echo '<option value="'.$i.'" selected="selected">'.($i+1).'</option>';
							}else{
								echo '<option value="'.$i.'" ">'.($i+1).'</option>';
							}
						}
					}else{
						echo '<option value="0">1</option>';
					}
				?>
			</select>
		</span>
		<a class="btn" href="<?php echo './student-dormitory-exchanging.php?&grade='.$grade.'&major='.$major.'&class='.$class.'&page='.($page+1<$pageMax?$page+1:$page).'&pageSize='.$pageSize.'&search='.$search; ?>">下一页</a>
	</div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="scripts/student-dormitory-exchanging.jquery.js"></script>
<script type="text/javascript">

</script>
</body>
</html>